public class test4 {
    /**
     * Definition for a binary tree node.
     * public class TreeNode {
     *     int val;
     *     TreeNode left;
     *     TreeNode right;
     *     TreeNode() {}
     *     TreeNode(int val) { this.val = val; }
     *     TreeNode(int val, TreeNode left, TreeNode right) {
     *         this.val = val;
     *         this.left = left;
     *         this.right = right;
     *     }
     * }
     */
        public int sumOfLeftLeaves(TreeNode root) {
            //只要叶子！
            int res = 0;
            if(root==null){
                return 0;
            }
            Queue<TreeNode> queue = new LinkedList<>();
            queue.offer(root);
            while(!queue.isEmpty()){
                TreeNode tmpNode = queue.poll();
                if(tmpNode.left!=null){
                    if(tmpNode.left.left==null && tmpNode.left.right==null){
                        res += tmpNode.left.val;
                    }
                    queue.offer(tmpNode.left);
                }
                if(tmpNode.right!=null){
                    queue.offer(tmpNode.right);
                }
            }
            return res;
        }
}
